package com.bootmybatisdemo.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2021/05/26 11:13
 * Description: 文件上传路径映射配置
 * Version: V1.0
 */
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer {

    @Value("${file.uploadFolder}")
    private String uploadFolder;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**").addResourceLocations("file:"+uploadFolder+"/");
    }
}

